package com.jerry.graphql.domain;

import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;

@Controller
public class Query {

    @QueryMapping(name = "findBookById")
    public Book findBookById(@Argument(name = "id") String id) {
        // You should implement your logic to fetch data from DB or any other source.
        // For simplicity, I'll just return a dummy book.
        Book book = new Book();
        book.setId(id);
        book.setName("Sample Book");
        book.setPageCount(123);
        Author author = new Author();
        author.setId("1");
        author.setName("Sample Author");
        book.setAuthor(author);
        return book;
    }
}